﻿using DevExpress.XtraEditors.Controls;
using RecruitStudents.Utility.Helper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace RecruitStudents.Client
{
    class LocalizationCHS : DevExpress.XtraEditors.Controls.Localizer
    {
        public override string GetLocalizedString(DevExpress.XtraEditors.Controls.StringId id)
        {
            switch (id)
            {
                case StringId.XtraMessageBoxCancelButtonText:
                    return "取消";
                case StringId.XtraMessageBoxOkButtonText:
                    return "确定";
                case StringId.XtraMessageBoxYesButtonText:
                    return "是";
                case StringId.XtraMessageBoxNoButtonText:
                    return "否";
                case StringId.XtraMessageBoxIgnoreButtonText:
                    return "忽略";
                case StringId.XtraMessageBoxAbortButtonText:
                    return "中止";
                case StringId.XtraMessageBoxRetryButtonText:
                    return "重试";
                default:
                    return base.GetLocalizedString(id);
            }
        }
    }
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            DevExpress.Skins.SkinManager.EnableFormSkins();
            DevExpress.XtraEditors.Controls.Localizer.Active = new LocalizationCHS();
            System.Threading.Mutex mutex = new System.Threading.Mutex(false, "SINGLE_INSTRANCE_MUTEX");
            if (!mutex.WaitOne(0, false))
            {
                mutex.Close();
                mutex = null;
            }
            if (mutex == null)
            {
                MessageBox.Show("已经有一个程序在运行了，请检查");
            }
            else
            {
                Login loginForm = new Login();
                loginForm.ShowDialog();
                //try
                //{
                //    if (SessionerHelper.UserType == "1")//考务选择3个
                //    {
                //        ChooseForm_SpecialityKinds SpecialityKinds = new ChooseForm_SpecialityKinds();
                //        SpecialityKinds.ShowDialog();
                //    }
                //    else if (SessionerHelper.UserType == "2")//秘书选择4个
                //    {
                //        ChooseForm Choose_Form = new ChooseForm();
                //        Choose_Form.ShowDialog();
                //    }
                //    else if (SessionerHelper.UserType == "4")//信息录入选择1个
                //    {
                //        ChooseForm_ExamPlace examPlace = new ChooseForm_ExamPlace();
                //        examPlace.ShowDialog();
                //    }
                //    else if (SessionerHelper.UserType == "5")//信息录入选择1个
                //    {
                //        ChooseForm_ExamPlace examPlace = new ChooseForm_ExamPlace();
                //        examPlace.ShowDialog();
                //    }
                //}
                //catch
                //{ }
                try
                {
                    if (!String.IsNullOrEmpty(SessionerHelper.LoginName))
                    {
                        Application.Run(new Main());
                    }
                    else
                    {
                        Application.Exit();
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            }
        }
    }
}
